package oop2;

import java.util.Scanner;

public class BanjiOperate {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        BanJi a = new BanJi();
        a.name = "java82";
        a.teacher = "刘老师";
        int choice = 0;

        while (true) {
            System.out.println("1:加新生，2:查看班级信息，3:找人，4:按照范围查找人，5:修改学生姓名，6:查找指定位置的学生姓名，9:退出");
            choice = input.nextInt();
            if (choice == 1) {
                System.out.print("请输入新生的名字:");
                String newStu = input.next();
                a.addNewStu(newStu);
                // a.addNewStu(input.next());
            } else if (choice == 2) {
                a.showCisInfo();
            } else if (choice == 3) {
                System.out.print("输入查找的名字:");
                String name = input.next();
                boolean b = a.search(name);
                System.out.println("这个人" + (b ? "在" : "不在") + "班级");
            } else if (choice == 4) {
                System.out.print("输入查找的名字:");
                String name = input.next();
                System.out.print("输入查找的起始地址:");
                int start = input.nextInt();
                System.out.print("输入查找的终点地址:");
                int end = input.nextInt();
                boolean b = a.search(start, end, name);
                System.out.println("这个人" + (b ? "在" : "不在") + "班级");
            } else if (choice == 5) {
                System.out.print("输入要修改的学生旧名字和新名字:");
                String oldName = input.next();
                String newName = input.next();
                boolean b = a.modify(oldName, newName);
                System.out.println("修改的结果是:" + b);
            } else if (choice == 6) {
                System.out.println("查找指定位置的学生姓名");
                System.out.print("输入指定位置:");
                int index = input.nextInt();
                System.out.println(a.find(index));
            } else if (choice == 9) {
                System.out.println("退出");
                break;
            }
        }

    }
}
